<template>
	<view>
		<view v-if="isFind">
			<messagesBox v-if="concernList.length!=0" :messagesList="concernList"></messagesBox>
			<view v-else class="empty">
				<span>暂时没有关注的人哦</span>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isloading: false,
				concernList: [],
				concernDate: '2099-12-31',
				concernMid: '',
				isFind: false
			};
		},
		created() {
			this.getMyConcernList()
		},
		methods: {
			async getMyConcernList(cb) {
				this.isloading = true

				if (this.concernList.length != 0 && this.concernList.length % 10 != 0) {
					uni.showToast({
						title: '没有更多数据数据',
						duration: 1500,
						icon: 'none'
					})
					return
				}


				let {
					data: res
				} = await uni.$http.get('/messages/listWhoseSubscribe?date=' + this.concernDate + '&mid=' + this
					.concernMid)

				this.isFind = true
				cb && cb()
				this.isloading = false

				if (res.code == 2000) {
					this.concernList = [...this.concernList, ...res.data]
					this.concernDate = res.data[res.data.length - 1].date
					this.concernMid = res.data[res.data.length - 1].mid
				} else {
					uni.showToast({
						title: '数据加载出错',
						duration: 1500,
						icon: "error"
					})
				}
			}
		},
		onPullDownRefresh() {
			this.concernList = []
			this.concernDate = '2022-12-31'
			this.concernMid = ''
			this.isFind = false
			this.getMyConcernList(() => uni.stopPullDownRefresh())
		},
		onReachBottom() {
			if (this.isloading) return
			this.getMyConcernList()
		}
	}
</script>

<style lang="less">
	.empty {
		display: flex;
		justify-content: center;
		align-items: flex-end;
		font-size: 14px;
		color: #dedede;
		width: 100%;
		height: 300px;
		background: url('@/static/images/empty-image-default.png') no-repeat;
		background-size: 50%;
		background-position: 50% 50%;
	}
</style>
